package com.itheima.pojo;

import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * @author GG
 * @version 1.0
 * @date 2021/10/30 8:56
 */
public class TestMain {

    public static void main(String[] args) {
        //初始化ioc容器
//        ApplicationContext  ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
        //了解即可,实际开发中,不会使用
        ApplicationContext  ctx=new FileSystemXmlApplicationContext("D:\\ssm136\\day01_2_ioc_xml\\src\\main\\resources\\applicationContext.xml");
        //获取bean对象 根据bean的名称获取bena,返回Object,需要强转
//        UserService bean = (UserService) ctx.getBean("userService1");
        //根据bean的名称和类型获取bean,不需要强转的
        UserService bean =  ctx.getBean("userService1",UserService.class);
        bean.add();
    }

}
